package com.gexiaobao.pigeon.ui.adapter

import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.gexiaobao.pigeon.R
import com.gexiaobao.pigeon.app.model.bean.TraPassListResponse

/**
 * @Author      : hxw
 * @Date        :2023/2/7 14:59
 * @Describe    :
 */
class TraPassListAdapter(data: ArrayList<TraPassListResponse.DataList>) :
    BaseQuickAdapter<TraPassListResponse.DataList, BaseViewHolder>(R.layout.item_training_pass, data) {

    //    @RequiresApi(Build.VERSION_CODES.M)
    override fun convert(holder: BaseViewHolder, item: TraPassListResponse.DataList) {
        holder.setText(R.id.tv_item_training_pass_fly_dis, item.trainingDis)
        holder.setText(R.id.tv_item_training_pass_sign_up_time, item.loadTime)
        holder.setText(R.id.tv_item_training_pass_match_time, item.flyTime)

        var statusStr = context.getString(R.string.item_train_fly_main_list_not_start)
        var statusColor = context.resources.getColor(R.color.color_8F8F8F)
        var statusIcon = R.mipmap.profilepic_str_1

        when (item.passStatus) {
            1 -> {
                statusStr = context.getString(R.string.item_train_fly_main_list_not_start)//"未开始"
                statusColor = context.resources.getColor(R.color.race_blue)
                statusIcon = R.mipmap.training_blue
            }

            2 -> {
                statusStr = context.getString(R.string.study_in_finland)//"报名中"
                statusColor = context.resources.getColor(R.color.race_orange)
                statusIcon = R.mipmap.training_orange
            }

            3 -> {
                statusStr = context.getString(R.string.Registration_closed)//"报名结束"
                statusColor = context.resources.getColor(R.color.race_grey)
                statusIcon = R.mipmap.training_grey
            }

            4 -> {
                statusStr = context.getString(R.string.Pigeons_gathering)//"集鸽中"
                statusColor = context.resources.getColor(R.color.race_blue)
                statusIcon = R.mipmap.training_blue
            }

            5 -> {
                statusStr = context.getString(R.string.End_of_collection)//"集鸽结束"
                statusColor = context.resources.getColor(R.color.race_grey)
                statusIcon = R.mipmap.training_grey
            }

            6 -> {
                statusStr = context.getString(R.string.in_the_game)//"比赛中"
                statusColor = context.resources.getColor(R.color.race_red)
                statusIcon = R.mipmap.training_red
            }

            7 -> {
                statusStr = context.getString(R.string.end_of_game)//"比赛结束"
                statusColor = context.resources.getColor(R.color.race_grey)
                statusIcon = R.mipmap.training_grey
            }

            8 -> {
                statusStr = context.getString(R.string.train_fly_detail_detail_fragment_not_started)//"开始中"
                statusColor = context.resources.getColor(R.color.race_blue)
                statusIcon = R.mipmap.training_blue
            }

            9 -> {
                statusStr = context.getString(R.string.est_pigeon_centring)//"验鸽中"
                statusColor = context.resources.getColor(R.color.race_blue)
                statusIcon = R.mipmap.training_blue
            }

            10 -> {
                statusStr = context.getString(R.string.finished)//"结束中"
                statusColor = context.resources.getColor(R.color.race_grey)
                statusIcon = R.mipmap.training_grey
            }

        }
        holder.setText(R.id.tv_item_training_pass_status, statusStr)
        holder.setTextColor(R.id.tv_item_training_pass_status, statusColor)
        holder.setBackgroundResource(R.id.iv_item_training_pass_icon, statusIcon)

    }
}